package com.example.demo.线程;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.FutureTask;

/**
 * @description:
 * @projectName:demo
 * @see:线程
 * @author:袁成龙
 * @createTime:2020/10/6 19:12
 * @version:1.0
 */
public class TestThead {

    public static void main(String[] args) throws Exception{

        List<Integer> list = new ArrayList<>();

        TestRunnd2 testRunnd2 = new TestRunnd2(list);
        TestRunnd2 testRunnd1 = new TestRunnd2(list);

        FutureTask<String> task = new FutureTask<String>(new TestCallAble());
        Thread threadtask = new Thread(task);


        Thread thread = new Thread(testRunnd2);
        Thread thread1 = new Thread(testRunnd1);

        threadtask.start();
        thread.start();
        thread1.start();

        thread.join();
        thread1.join();
        String s = task.get();
        //等待时间的限制
       // task.get(1, TimeUnit.SECONDS);
        System.out.println(s);

        System.out.println("============"+list.size());
    }



}